<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class MainController extends AdminbaseController {
	
    public function index(){
    	
    	$mysql= M()->query("select VERSION() as version");
    	$mysql=$mysql[0]['version'];
    	$mysql=empty($mysql)?L('UNKNOWN'):$mysql;
    	
    	//server infomaions
    	$info = array(
    			L('OPERATING_SYSTEM') => PHP_OS,
    			L('OPERATING_ENVIRONMENT') => $_SERVER["SERVER_SOFTWARE"],
    			L('PHP_RUN_MODE') => php_sapi_name(),
    			L('MYSQL_VERSION') =>$mysql,
    			L('PROGRAM_VERSION') => SIMPLEWIND_CMF_VERSION . "&nbsp;&nbsp;&nbsp; [<a href='http://www.thinkcmf.com' target='_blank'>ThinkCMF</a>]",
    			L('UPLOAD_MAX_FILESIZE') => ini_get('upload_max_filesize'),
    			L('MAX_EXECUTION_TIME') => ini_get('max_execution_time') . "s",
    			L('DISK_FREE_SPACE') => round((@disk_free_space(".") / (1024 * 1024)), 2) . 'M',
    	);
		$posts=M('posts');
		
		$map['post_type'] = array('EQ','2');
		$c_posts=$posts->count();
		$p_posts=$posts->where($map)->count();//单页数量
		$a_posts=$c_posts-$p_posts;//文章数量
		//昨日文章
		$starttime_l=date('Y-m-d 00:00:00', strtotime("-1 day")) ;
		$endtime_l=date('Y-m-d 23:59:59',strtotime("-1 day")) ;
		$map_l['post_date']=array('between',array($starttime_l,$endtime_l));
		$posts_l=$posts->where($map_l)->count();
	
		//今日文章
		$starttime_j=date('Y-m-d 00:00:00', strtotime("0 day")) ;
		$endtime_j=date('Y-m-d 23:59:59',strtotime("0 day")) ;
		$map_j['post_date']=array('between',array($starttime_j,$endtime_j));
		$posts_j=$posts->where($map_j)->count();
		$user=M('users');
		$c_user=$user->where('user_status=1')->count();//用户数量
		$this->assign('c_user', $c_user);	
		$this->assign('a_posts', $a_posts);	
		$this->assign('p_posts', $p_posts);
		$this->assign('posts_l', $posts_l);
		$this->assign('posts_j', $posts_j);
		
    	$this->assign('server_info', $info);
    	$this->display();
    
    }
}